sap.ui.define([
		"sap/ui/base/ManagedObject",
		"sap/ui/core/Fragment",
		"sap/ui/core/syncStyleClass"
	],
	function(ManagedObject, Fragment, syncStyleClass) {
		"use strict";

		return ManagedObject.extend("com.wp.SWIFTSAP.controller.ItemDetailDialog", {
			constructor: function(oView) {
				this._oView = oView;
			},
			exit: function() {
				delete this._oView;
			},
			open: function() {
				var oView = this._oView;
				//如果没有相应Dialog，就调用sap.ui.xmlfragment实例化Fragment
				// create dialog lazily
				if (!oView.byId("itemDetailDialog")) {
					var oFragmentController = {
						onOkDialog: function() {
							oView.byId("itemDetailDialog").close();
						}
					};
					// load asynchronous XML fragment
					Fragment.load({
						id: oView.getId(),
						name: "com.wp.SWIFTSAP.view.ItemDetail",
						controller: oFragmentController
					}).then(function(oDialog) {
						// connect dialog to the root view of this component (models, lifecycle)
						//该Dialog依赖于oView, oView销毁它也销毁了
						oView.addDependent(oDialog);
						// forward compact/cozy style into dialog
						syncStyleClass(oView.getController().getOwnerComponent().getContentDensityClass(), oView, oDialog);
						oDialog.open();
					});
				} else {
					oView.byId("itemDetailDialog").open();
				}
			}
		});
	});